package vn.bk.hotel.dialog;

import vn.bk.hotel.R;
import vn.bk.hotel.SearchByLandmark;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ChooseLandmarks {
    private Dialog dialog;

    public ChooseLandmarks(Context paramContext, int paramInt) {
	this.dialog = new Dialog(paramContext);
	this.dialog.setTitle(paramContext
		.getString(R.string.dialog_choose_landmark_title));
	View localView = View.inflate(paramContext,
		R.layout.dialog_choose_city, null);
	ListView localListView = (ListView) localView
		.findViewById(R.id.list_city);
	final String[] allLandmarks;
	switch (paramInt) {
	case 0:
	    allLandmarks = paramContext.getResources().getStringArray(
		    R.array.landmark_hn_text);
	    break;
	case 1:
	    allLandmarks = paramContext.getResources().getStringArray(
		    R.array.landmark_hcm_text);
	    break;
	case 2:
	    allLandmarks = paramContext.getResources().getStringArray(
		    R.array.landmark_dn_text);
	    break;
	case 3:
	    allLandmarks = paramContext.getResources().getStringArray(
		    R.array.landmark_hp_text);
	    break;
	default:
	    allLandmarks = paramContext.getResources().getStringArray(
		    R.array.landmark_hn_text);
	    break;

	}
	
	localListView.setAdapter(new ArrayAdapter<String>(paramContext,
		android.R.layout.simple_list_item_1, allLandmarks));
	localListView.setOnItemClickListener(new OnItemClickListener() {

	    @Override
	    public void onItemClick(AdapterView<?> parent, View view,
		    int position, long id) {
		SearchByLandmark.changeLandmark(position, allLandmarks[position]);
		dialog.dismiss();
	    }
	});
	
	dialog.setContentView(localView);
    }

    public void show() {
	this.dialog.show();
    }
}
